<?php

namespace Xin\Process\Python;

use Symfony\Component\Process\InputStream;
use Symfony\Component\Process\Process;
use Xin\Process\AppWork;

abstract class PythonAppWork extends AppWork
{

	/**
	 * @inerhitDoc
	 */
	protected function makeProcessFromShellCommandline($command, string $workDirectoryPath, array $envs = [], InputStream $input = null, ?float $timeout = null)
	{
		return Python::fromShellCommandline(
			$command,
			$workDirectoryPath,
			$envs,
			$input,
			$timeout
		);
	}

	/**
	 * @inerhitDoc
	 */
	protected function pretreatmentProcess(Process $process, $projectName): Process
	{
		if ($process instanceof Python && $condaEnv = $this->getDefaultCondaEnv()) {
			$process->useCondaEnv($condaEnv);
		}

		return $process;
	}

	/**
	 * @inerhitDoc
	 */
	protected function getDefaultCondaEnv()
	{
		return null;
	}
}
